package com.xy.example2;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/14 10:15
 * @description
 */
public class Client {
    public static void main(String[] args) {

        // 张三骑车使用中，未归还
        BikeFlyweight bike1 = BikeFlyweightFactory.getInstance().getBike();
        bike1.ride(new User("张三"));
        // bike1.back();

        // 李四租赁单车并归还
        BikeFlyweight bike2 = BikeFlyweightFactory.getInstance().getBike();
        bike2.ride(new User("李四"));
        bike2.back();

        // 王五租赁单车
        BikeFlyweight bike3 = BikeFlyweightFactory.getInstance().getBike();
        bike3.ride(new User("王五"));
        bike3.back();

        System.out.println("张三骑的车 == 李四骑的车" +  (bike1 == bike2));
        System.out.println("李四骑的车 == 王五骑的车" +  (bike3 == bike2));
    }
}
